1. /* getstr.cpp by K.Tsuru */
  2. /****************
  3. string type
  4. *****************/
  5. #if 1 ////iostream version///////////////////////
  6. #include <iostream>
  7. using namespace std;
  8. char* GetString(){
  9. string buff;
  10. cin >> buff;
  11. return (char*)buff.c_str(); // needs cast (const char*) --> (char*)
  12. }
  13. #else /////ncblock version//////////////////////
  14. #include "getnum.h"
  15. #include "ncblock.h"
  16. static NCBlock <char> buff;
  17. char* GetString(){
  18. int c;
  19. uint len = 0;
  20. buff.size(4, -1);
  21. while(1){
  22. c = getchar();
  23. buff.reserve(len);
  24. if(c == '\n'){
  25. buff[len] = '\0';
  26. break;
  27. }
  28. buff[len++] = (char)(c & 0xff);
  29. }
  30. return buff.Elements();
  31. }
  32. #endif

getstr.cpp : last modifiled at 2017/05/24 11:20:49(679 bytes)
created at 2016/04/11 11:17:20
The creation time of this html file is 2017/10/07 10:54:15 (Sat Oct 07 10:54:15 2017).